<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <!-- 1、引入依赖 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <div id="app"></div>

  <!-- 2、编写react代码 -->
  <script type="text/babel">

    class App extends React.Component {

      constructor(props){
        super(props)
        this.state = {
          isLogin: false,
        }
      }

      // 所有组件必须实现render方法
      render() {
        const { isLogin } = this.state
        const titleValue = isLogin ? 'block' : 'none'
        // 必须用return返回
        return (
          // {}语法  里面可以是表达式
          <div>
            <button onClick={() => this.btnClick()}>{isLogin ? '退出' : '登录'}</button>
            <h2 style={{display: isLogin ? 'block' : 'none'}}>你好呀</h2>
            <h2 style={{display: titleValue}}>你好呀</h2>
          </div>
        )
      }

      btnClick(){
        const {isLogin} = this.state
        this.setState({
          isLogin: !isLogin
        })
      }
    }


    ReactDOM.render(<App/>, document.getElementById('app')) 
  </script>
</body>
</html>